<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div ui-layout-center">
        <div class="row">
            <div class="col-sm-12 select-info">
                <form id="leave-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                请假类型：<select name="leaveType" th:with="type=${@dict.getType('sys_leave_type')}">
                                <option value="">所有</option>
                                <option th:each="e : ${type}" th:text="${e['dictLabel']}" th:value="${e['dictValue']}"></option>
                            </select>
                            </li>
                            <li>
                                请假人：<input type="text" name="leavePeople"/>
                            </li>
                            <li>
                                审批状态：<select name="status" th:with="type=${@dict.getType('sys_daily_approve')}">
                                <option value="">所有</option>
                                <option th:each="e : ${type}" th:text="${e['dictLabel']}" th:value="${e['dictValue']}"></option>
                            </select>
                            </li>
                            <li class="select-time">
                                <label>请假时间： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <!--<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="module:leave:export"><i class="fa fa-download"></i>&nbsp;导出</a>-->
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group hidden-xs" id="toolbar" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="module:leave:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.removeAll()" shiro:hasPermission="module:leave:remove">
                    <i class="fa fa-trash-o"></i> 删除
                </a>
                <a class="btn btn-success btn-outline btn-rounded" onclick="$.table.exportExcel()" shiro:hasPermission="module:leave:export">
                    <i class="fa fa-download"></i>&nbsp;导出
                </a>
            </div>

            <div class="col-sm-12 select-info table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('module:leave:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:leave:remove')}]];
        var datas = [[${@dict.getType('sys_daily_approve')}]];
        var leaveTypeData = [[${@dict.getType('sys_leave_type')}]];
        var prefix = ctx + "module/leave"

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                sortName: "createTime",
                sortOrder: "desc",
                modalName: "请假管理",
                search: false,
                showExport: false,// 是否支持导出文件
                showRefresh:false,// 是否显示刷新按钮
                showColumns :false,// 是否显示隐藏某列下拉框
                showToggle:false,// 是否显示详细视图和列表视图的切换按钮
                columns: [{
		            checkbox: true
		        },
				// {
				// 	field : 'leaveId',
				// 	title : '序号'
				// },
				// {
				// 	field : 'leaveTitle',
				// 	title : '请假标题'
				// },
                {
                    field : 'leaveType',
                    title : '请假类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(leaveTypeData, value);
                    }
                },
				{
					field : 'leavePeople', 
					title : '请假人' 
				},
				{
					field : 'beginDate', 
					title : '请假开始时间' 
				},
				{
					field : 'endDate', 
					title : '请假结束时间' 
				},
				{
					field : 'dayNum', 
					title : '请假天数' 
				},
				{
                    field: 'dept.deptName',
					title : '所属部门' 
				},
				{
					field : 'leaveReason', 
					title : '请假原因' 
				},
				{
					field : 'user.userName',
					title : '审批人'
				},
                {
                    field : 'leaveStatus',
                    title : '审批状态' ,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
				{
					field : 'opinion',
					title : '审批意见'
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.leaveId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.leaveId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>